#ifndef _refine_refine3_h_
#define _refine_refine3_h_

#include "types.h"
#include "information_source.h"
#include "typelib/affine.h"

namespace refine {

namespace refine3 {

typedef img::bitmap mask;
typedef bool mask_value;

enum change_type {
	turn_on_and_off,
	turn_on_only,
	turn_off_only
};

enum information {
	info_lightness,
	info_color,
	info_all
};

struct params 
{
	params(); ///< loads default params

	float	t; ///< decision threshold, >1
	int		max_passes; ///< [1, ...]
	information consider;
	change_type change;
	preference prefer;
	bool	silent;

	mask *	modifiable; ///< 0 means every pixel is permitted to change
};

bool operator == (const params & lhs, const params & rhs);

/// refine in one (target) frame without teacher
void adjust(
	const byte_image & im, mask & m, 
	const params & p = params(),
	bool check_once = false ///< don't test a pixel again after mask value for it was changed once
);
void adjust(
	const argb_byte_image & im, mask & m, 
	const params & p = params(),
	bool check_once = false ///< don't test a pixel again after mask value for it was changed once
);

/// transfer mask from reference frame to target frame using predicted motion if available
void track(
	const byte_image & ref_im, const mask & ref_m, 
	const byte_image & tgt_im, mask & tgt_m, 
	information_source isource,
	const affine * motion = 0,	///< contains estimated transformtaion of object from reference to target frames
	const params & p = params()
);

} //namespace refine3

} //namespace refine

#endif //_refine_refine3_h_
